import request from '@/config/axios'

// CRM 专利信息 VO
export interface PatentVO {
  id: number // 编号
  customerId: number // 客户id
  customerName?: string // 客户名称
  createTime: Date // 创建时间
  updateTime: Date // 更新时间
  creator: string // 创建人
  creatorName?: string // 创建人名称
  updater: string // 修改人
  updaterName?: string // 修改人名称
  auditStatus: number // 审核状态
  processInstanceId?: string // 审核流程实例编号
}

// CRM 专利信息 API
export const PatentApi = {
  // 查询CRM 专利信息分页
  getPatentPage: async (params: any) => {
    return await request.get({ url: `/crm/patent/page`, params })
  },

  // 查询CRM 专利信息详情
  getPatent: async (id: number) => {
    return await request.get({ url: `/crm/patent/get?id=` + id })
  },

  // 专利信息审核
  submit: async (ids: number[],isReCreate: boolean) => {
    return await request.put({ url: `/crm/patent/submit`,params: { ids: ids.join(',') ,isReCreate: isReCreate }} )
  },

  // 根据客户查询CRM 专利信息详情
  getPatentByCustomerId: async (customerId: number) => {
    return await request.get({ url: `/crm/patent/getByCustomerId?customerId=` + customerId })
  },

  // 新增CRM 专利信息
  createPatent: async (data: PatentVO) => {
    return await request.post({ url: `/crm/patent/create`, data })
  },

  // 修改CRM 专利信息
  updatePatent: async (data: PatentVO) => {
    return await request.put({ url: `/crm/patent/update`, data })
  },

  // 删除CRM 专利信息
  deletePatent: async (id: number) => {
    return await request.delete({ url: `/crm/patent/delete?id=` + id })
  },

  // 导出CRM 专利信息 Excel
  exportPatent: async (params) => {
    return await request.download({ url: `/crm/patent/export-excel`, params })
  },

// ==================== 子表（CRM 专利信息-明细） ====================

  // 获得CRM 专利信息-明细列表
  getPatentItemsListByPatentId: async (patentId) => {
    return await request.get({ url: `/crm/patent/patent-items/list-by-patent-id?patentId=` + patentId })
  },
}
